home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Blitter / DrawPixel.s < prev    next >
Encoding:
Text File  |  1997-05-01  |  2.9 KB  |  130 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Draw Pixel
  3. ;----------
  4. ;Draws a pixel on a screen without destroying the background.
  5. ;
  6.  
  7.     INCDIR    "INCLUDES:"
  8.     INCLUDE    "games/games_lib.i"
  9.     INCLUDE    "games/games.i"
  10.  
  11. CALL    MACRO
  12.     jsr    _LVO\1(a6)
  13.     ENDM
  14.  
  15.     SECTION    "DrawPixel",CODE
  16.  
  17. ;===========================================================================;
  18. ;                             INITIALISE DEMO
  19. ;===========================================================================;
  20.  
  21.     STARTGMS
  22.  
  23. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  24.     move.l    GMSBase(pc),a6    ;Activate user preferences.
  25.     CALL    AllocBlitter    ;Allocate the blitter.
  26.     tst.l    d0
  27.     bne    .Error_Blitter
  28.  
  29.     lea    FILE_Background(pc),a1    ;Load the picture.
  30.     moveq    #GETPALETTE|VIDEOMEM,d0
  31.     CALL    LoadPicFile
  32.     move.l    d0,PIC_Background
  33.     beq.s    .Error_Picture
  34.  
  35.     CALL    GetScreen
  36.     move.l    d0,Screen
  37.     beq.s    .Error_Screen
  38.     move.l    d0,a0
  39.     move.l    PIC_Background(pc),a1
  40.     move.w    #320,GS_ScrWidth(a0)
  41.     move.w    #256,GS_ScrHeight(a0)
  42.     move.l    PIC_AmtColours(a1),GS_AmtColours(a0)
  43.     move.w    PIC_Planes(a1),GS_Planes(a0)
  44.     move.w    PIC_Width(a1),GS_PicWidth(a0)
  45.     move.w    PIC_Height(a1),GS_PicHeight(a0)
  46.     move.l    PIC_Palette(a1),GS_Palette(a0)
  47.     move.l    PIC_Data(a1),GS_MemPtr1(a0)
  48.     move.w    PIC_ScrMode(a1),GS_ScrMode(a0)
  49.     move.w    PIC_ScrType(a1),GS_ScrType(a0)
  50.     CALL    AddScreen
  51.     tst.l    d0
  52.     beq.s    .Error_Screen
  53.  
  54.     CALL    ShowScreen
  55.  
  56.     CALL    InitJoyPorts
  57.  
  58.     bsr.s    Main
  59.  
  60. .ReturnToDOS
  61.     move.l    GMSBase(pc),a6
  62.     move.l    Screen(pc),a0
  63.     CALL    DeleteScreen
  64. .Error_Screen
  65.     move.l    PIC_Background(pc),a1
  66.     CALL    FreePic
  67. .Error_Picture
  68.     CALL    FreeBlitter
  69. .Error_Blitter
  70.     MOVEM.L    (SP)+,A0-A6/D1-D7
  71.     moveq    #ERR_OK,d0
  72.     rts
  73.  
  74. ;===========================================================================;
  75. ;                                MAIN LOOP
  76. ;===========================================================================;
  77.  
  78. Main:    move.l    GMSBase(pc),a6
  79.  
  80.     moveq    #100,d6
  81.     moveq    #100,d7
  82.  
  83. .loop    move.l    Screen(pc),a0
  84.     moveq    #BUFFER1,d0
  85.     movem.w    OldPixel(pc),d1/d2/d3
  86.     tst.w    d3
  87.     blt.s    .read
  88.     CALL    DrawPixel    ;>> = Draw the old background pixel.
  89.  
  90. .read    moveq    #BUFFER1,d0    ;d0 = Buffer to read.
  91.     move.w    d6,d1    ;d1 = X Coordinate.
  92.     move.w    d7,d2    ;d2 = Y Coordinate.
  93.     CALL    ReadPixel    ;>> = Read the pixel.
  94.     movem.w    d6/d7,OldPixel    ;MA = Save coords of next pixel.
  95.     move.w    d0,OldPixel+4    ;MA = Save colour of next pixel.
  96.  
  97.     moveq    #BUFFER1,d0    ;d0 = Buffer.
  98.     move.w    #3,d3    ;d3 = Colour.
  99.     CALL    DrawPixel    ;>> = Draw our pixel.
  100.     CALL    WaitVBL    ;>> = Wait for VBL.
  101.  
  102.     moveq    #JPORT1,d0    ;Read the mouse, then update the
  103.     moveq    #JT_ZBXY,d1    ;BOB's X and Y co-ordinates.
  104.     CALL    ReadJoyPort
  105.     move.w    d0,d1
  106.     ext.w    d0
  107.     asr.w    #8,d1
  108.     add.w    d0,d7
  109.     add.w    d1,d6
  110.     btst    #MB_LMB,d0
  111.     beq.s    .loop
  112.     rts
  113.  
  114. OldPixel:
  115.     dc.w    0,0,-1
  116.  
  117. ;===========================================================================;
  118. ;                                  DATA
  119. ;===========================================================================;
  120.  
  121. Screen:    dc.l    0
  122.  
  123. PIC_Background:
  124.     dc.l    0
  125.  
  126. FILE_Background:
  127.     dc.b    "GMS:demos/data/PIC.Green",0
  128.     even
  129.  
  130.